home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Estructuras básicas / RandomClear / RandomClear.cs next >
Encoding:
Text File  |  2002-04-22  |  746 b   |  27 lines

  1. //------------------------------------------
  2. // RandomClear.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class RandomClear: Form 
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new RandomClear());
  13.      }
  14.      public RandomClear()      
  15.      {
  16.           Text = "Cambio de color aleatorio";
  17.      }
  18.      protected override void OnPaint(PaintEventArgs pea)
  19.      {
  20.           Graphics grfx = pea.Graphics;
  21.           Random   rand = new Random();
  22.  
  23.           grfx.Clear(Color.FromArgb(rand.Next(256),
  24.                                     rand.Next(256),
  25.                                     rand.Next(256)));
  26.      }
  27. }